from ete4 import Tree

# Let's create a simple tree.

t = Tree('((((H,K),(F,I)G),E),((L,(N,Q)O),(P,S)));', parser=1)

print('Original tree looks like this:')
print(t)
#      ╭─┬╴H
#    ╭─┤ ╰╴K
#  ╭─┤ ╰─┬╴F
#  │ │   ╰╴I
# ─┤ ╰╴E
#  │ ╭─┬╴L
#  ╰─┤ ╰─┬╴N
#    │   ╰╴Q
#    ╰─┬╴P
#      ╰╴S

# Prune the tree in order to keep only some leaf nodes.
t.prune(['H','F','E','Q', 'P'])
print('Pruned tree')
print(t)
#    ╭─┬╴H
#  ╭─┤ ╰╴F
# ─┤ ╰╴E
#  ╰─┬╴Q
#    ╰╴P
